/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Simulateur.java
 *
 * Created on 5 nov. 2010, 08:45:53
 */

package IHM;

import IHM.IHMSimulatorAddRequestDialog.MODE;
import Simulator.DriverLift;
import Simulator.Simulator;
import EcoSpeed.Alarme;

import EcoSpeed.Utils;
import Simulator.Request;
import SimulatorStandard.StandardDriverLift;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
import java.util.Observable;
import java.util.Observer;
import java.util.Vector;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.UIManager.LookAndFeelInfo;
import javax.swing.UnsupportedLookAndFeelException;
import javax.swing.table.DefaultTableModel;


/**
 *
 * @author pierre.gillon
 */
public class IHMSimulator extends javax.swing.JFrame {

    // Objet stockant l'instance du l'ihm.
    private IHMSimulator instance;

    // Objet représentant le simulateur
    private Simulator simulatorController;

    // Fichiers de quotas et de tests
    private File testFileOpened;
    private File quotaFileOpened;
    private File statsFileOpened;

    // Popup d'ajout d'une requete.
    private IHMSimulatorAddRequestDialog dialogTest;
    private IHMSimulatorAddQuotaDialog dialogQuota;
    private IHMSimulatorUpdateDate dialogDate;

    // Tableau de tous les lookandfeel dispo
    private LookAndFeelInfo[] lookAndFeelInfos;
    private int currentLookAndFeel;


    /** Creates new form Simulateur */
    public IHMSimulator(Simulator s) {
        // Paramètre null.
        if (s == null) {
            throw new NullPointerException("Impossible d'initialiser l'IHMSimulator, le simulateur passé en " +
                                           "paramètre est null.");
        }

        // Paramètre OK.
        else {
            // Affectation du controleur.
            simulatorController = s;
            instance = this;

            // Initialisation des composants graphiques.
            initComponents();

            jLB_SimulationSpeed.setText("x" + simulatorController.getSpeed());
            jLB_SimulationDate.setText(new SimpleDateFormat("EEEE d MMMM yyyy  HH:mm:ss").format(simulatorController.getDate()));

            // Mise à jour de la position
            this.setLocationRelativeTo(null);

            // Initialisation de la popup d'ajout d'une requete.
            dialogTest = new IHMSimulatorAddRequestDialog(this, true);
            dialogTest.setSize(420, 275);

            // Initialisation de la popup d'ajout d'un quota.
            dialogQuota = new IHMSimulatorAddQuotaDialog(this, true);
            dialogQuota.setSize(420,430);

            // Initialisation de la dialog de modification de la date
            dialogDate = new IHMSimulatorUpdateDate(this, true);

            // Initialisation des variables pour le lookandfeel
            lookAndFeelInfos = UIManager.getInstalledLookAndFeels();
            currentLookAndFeel = 0;

            // Réinitialisation des labels
            jLB_ConsoEcospeed.setText("0");
            jLB_ConsoStandard.setText("0");
            jLB_ProcessedRequestsEcospeed.setText("0");
            jLB_ProcessedRequestsStandard.setText("0");
            jLB_WaitingTimeEcospeed.setText("0");
            jLB_WaitingTimeStandard.setText("0");

            // Mise à jour de l'apparence de l'ihm.
            updateLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");

        }
    }

    /**
     * Méthode accessible depuis la popup d'ajout, pour ajouter une nouvelle requete.
     * @param d
     * @param startFloor
     * @param endFloor
     * @param weight
     * @param urgent
     */
    public void addNewRequest(String date, String startFloor, String endFloor, String weight, boolean priority)
    {
        DefaultTableModel model = (DefaultTableModel)jTable_Tests.getModel();

        // Ecriture dans le jTable_Tests
        model.addRow(new Object[]{ date,
                                   Integer.parseInt(startFloor),
                                   Integer.parseInt(endFloor),
                                   Integer.parseInt(weight),
                                   priority});
    }

    /**
     * Ajout directe d'une requête dans le simulateur sans passer par le jTable de jeu d'essai.
     * @param date
     * @param startFloor
     * @param endFloor
     * @param weight
     * @param priority
     */
    public void addDirectNewRequest(String date, String startFloor, String endFloor, String weight, boolean priority)
    {
        try {
            // Ajout des requêtes dans le simulateur.
            simulatorController.addRequest(new SimpleDateFormat("MM-dd-yyyy HH:mm:ss").parse(date), Integer.parseInt(startFloor), Integer.parseInt(endFloor), Integer.parseInt(weight), priority);

            }
        catch (ParseException ex) {
            MessageManager.ShowErrorMessage(this, MessageManager.errorInAddDirectRequest, ex);
        }
    }
    
    /**
     * Méthode d'ajout d'un quota dans le jTable prévu à cet effet.
     * @param startHour
     * @param endHour
     * @param startDay
     * @param endDay
     * @param startCallerFloor
     * @param endCallerFloor
     * @param startTargetFloor
     * @param endTargetFloor
     * @param nbRequests
     */
    public void addNewQuota(int startHour, int endHour, int startWeekDay, int endWeekDay,
                            int startCallerZone, int endCallerZone, int startTargetZone,
                            int endTargetZone, int hourlyRequestNumber)
    {
        DefaultTableModel model = (DefaultTableModel)jTable_Quotas.getModel();

        // Ecriture dans le jTable_Tests
        model.addRow(new Object[]{ startHour,
                                   endHour,
                                   startWeekDay,
				   endWeekDay,
                                   startCallerZone,
                                   endCallerZone,
                                   startTargetZone,
                                   endTargetZone,
                                   hourlyRequestNumber});
    }




    /**
     * Méthode de mise à jour de la date du simulateur.
     * @param date
     */
    public void updateDate(Date date)
    {
        simulatorController.setDate(date);
        jLB_SimulationDate.setText(new SimpleDateFormat("EEEE d MMMM yyyy  HH:mm:ss").format(date));
    }

    /**
     * Méthode de mise à jour de l'aspect graphique sur un style 'lookandfeel'.
     * @param style Chemin de package vers le 'laf' à appliquer.
     */
    private boolean updateLookAndFeel(String style) {
        try {

            UIManager.setLookAndFeel(style);
            SwingUtilities.updateComponentTreeUI(this);
            SwingUtilities.updateComponentTreeUI(dialogQuota);
            SwingUtilities.updateComponentTreeUI(dialogTest);
            SwingUtilities.updateComponentTreeUI(dialogDate);

            return true;
        }

        catch (ClassNotFoundException ex)
        {
            MessageManager.ShowErrorMessage(this, MessageManager.errorInLoadingLookAndFeel, ex);
        }
        catch (InstantiationException ex) {
            MessageManager.ShowErrorMessage(this, MessageManager.errorInLoadingLookAndFeel, ex);
        }
        catch (IllegalAccessException ex) {
            MessageManager.ShowErrorMessage(this, MessageManager.errorInLoadingLookAndFeel, ex);
        }
        catch (UnsupportedLookAndFeelException ex) {
            MessageManager.ShowErrorMessage(this, MessageManager.errorInLoadingLookAndFeel, ex);
        }
        return false;
    }

    /**
     * Méthode qui retourne la date maximum courante du jeu d'essai.
     * @return
     */
    public String getRequestMaxDate()
    {
        // Récupération du modèle.
        DefaultTableModel model = (DefaultTableModel) jTable_Tests.getModel();

        Date maxDate = null;
        SimpleDateFormat format = new SimpleDateFormat("MM-dd-yyyy HH:mm:ss");

        // Je parcours chaque ligne de mon jTable.
        for (int r = 0; r < model.getRowCount(); r++) {
            try {
                // Récupération des informations du Jtable.
                String date = (String) model.getValueAt(r, 0);
                Date d = format.parse(date);

                if (maxDate == null || d.after(maxDate)) {
                    maxDate = format.parse(date);
                }

            }
            catch (ParseException ex) {
                Logger.getLogger(IHMSimulator.class.getName()).log(Level.SEVERE, null, ex);
            }
        }

        return maxDate == null ? format.format(new Date()) : format.format(maxDate);
    }

    /**
     * Méthode qui retourne la date courante de la simulation. (Timeline)
     * @return
     */
    public String getCurrentSimulationDate(){
        return new SimpleDateFormat("MM-dd-yyyy HH:mm:ss").format(simulatorController.getDate());
    }




    /**
     * Méthode de chargement du fichier de configuration sur les jeux d'essais.
     */
    private boolean LoadTestFile() {
        if (testFileOpened == null)
            throw new NullPointerException("Aucun fichier de quota n'a été chargé.");

        FileReader fr = null;
        BufferedReader br = null;
        String lineData = null;

        // Récupération du modèle.
        DefaultTableModel model = (DefaultTableModel) jTable_Tests.getModel();
        
        try {

            // Instanciation des objets de manipulations de fichier.
            fr = new FileReader(testFileOpened);
            br = new BufferedReader(fr);

            // Tant qu'il reste des données
            while ((lineData = br.readLine()) != null) {
                try {

                    // Je récupère les blocks séparés par des espaces.
                    String[] blocks = lineData.split("  ");

                    // Récupération des informations du fichier.
                    String date = blocks[0];
                    String startFloor = blocks[1];
                    String endFloor = blocks[2];
                    String weight = blocks[3];
                    String priority = blocks[4];

                    // Ecriture dans le jTable_Tests
                    model.addRow(new Object[]{ date,
                                               Integer.parseInt(startFloor),
                                               Integer.parseInt(endFloor),
                                               Integer.parseInt(weight),
                                               priority.equals("0") == false});


                } catch (Exception ex) {
                    // Libère les ressources
                    br.close();
                    fr.close();

                    throw new Exception("Erreur lors du 'cast' des données du fichier de jeux d'essais.", ex);
                }

            }

            // Libère les ressources
            br.close();
            fr.close();

            return true;

        }
        catch (IOException ex) {
            //MessageManager.ShowErrorMessage(this, MessageManager.errorInOpeningFile, ex);
        }
        catch (Exception ex) {
            //MessageManager.ShowErrorMessage(this, MessageManager.errorInReadingFileFormat, ex);
        }

        return false;
    }

    /**
     * Méthode de chargement du fichier de quotas.
     * @return
     */
    private boolean LoadQuotaFile() {
        if (quotaFileOpened == null) {
            throw new NullPointerException("Aucun fichier de quota n'a été chargé.");
        }

        FileReader fr = null;
        BufferedReader br = null;
        String lineData = null;

        try {
            fr = new FileReader(quotaFileOpened);
            br = new BufferedReader(fr);

            // Récupération du modèle.
            DefaultTableModel model = (DefaultTableModel) jTable_Quotas.getModel();


            // Tant qu'il reste des données
            while ((lineData = br.readLine()) != null) {
                try {

                    // Je récupère les blocks séparés par des espaces.
                    String[] blocks = lineData.split(" ");

                    int startHour = Integer.parseInt(blocks[0]);
                    int endHour = Integer.parseInt(blocks[1]);
                    int startWeekDay = ((Integer.parseInt(blocks[2])+1)%7)+1;
                    int endWeekDay = ((Integer.parseInt(blocks[3])+1)%7)+1;
                    int startCallerZone = Integer.parseInt(blocks[4]);
                    int endCallerZone = Integer.parseInt(blocks[5]);
                    int startTargetZone = Integer.parseInt(blocks[6]);
                    int endTargetZone = Integer.parseInt(blocks[7]);
                    int hourlyRequestNumber = Integer.parseInt(blocks[8]);

                    // Ecriture dans le jTable_Quotas
		    this.addNewQuota(startHour, endHour, startWeekDay, endWeekDay, startCallerZone, endCallerZone, startTargetZone, endTargetZone, hourlyRequestNumber);

                } catch (Exception ex) {

                    // Libère les ressources
                    br.close();
                    fr.close();

                    throw new Exception("Erreur lors du 'cast' des données du fichier de quotas.", ex);
                }

            }

            // Libère les ressources
            br.close();
            fr.close();

            return true;

        }
        catch (IOException ex) {
            //MessageManager.ShowErrorMessage(this, MessageManager.errorInOpeningFile, ex);
        }
        catch (Exception ex) {
            //MessageManager.ShowErrorMessage(this, MessageManager.errorInReadingFileFormat, ex);
        }

        return false;
    }

    /**
     * Méthode de chargement du fichier de quotas.
     * @return
     */
    private boolean LoadStatsFile() {
        if (statsFileOpened == null) {
            throw new NullPointerException("Aucun fichier de stats n'a été chargé.");
        }

        FileReader fr = null;
        BufferedReader br = null;
        String lineData = null;

        try {
            fr = new FileReader(statsFileOpened);
            br = new BufferedReader(fr);

            // Récupération du modèle.
            DefaultTableModel model = (DefaultTableModel) jTable_Stats.getModel();
            while (model.getRowCount() != 0) {
                model.removeRow(0);
            }


            // Tant qu'il reste des données
            while ((lineData = br.readLine()) != null) {
                try {

                    // Je récupère les blocks séparés par des espaces.
                    String[] blocks = lineData.split(" ");

                    int day = Integer.parseInt(blocks[0]);
                    int hour = Integer.parseInt(blocks[1]);
                    int floor = Integer.parseInt(blocks[2]);
                    int requests = Integer.parseInt(blocks[3]);

                    // Ecriture dans le jTable_Stats
                    model.addRow(new Object[]{ day, hour, floor, requests});

                } catch (Exception ex) {

                    // Libère les ressources
                    br.close();
                    fr.close();

                    throw new Exception("Erreur lors du 'cast' des données du fichier de stats.", ex);
                }

            }

            // Libère les ressources
            br.close();
            fr.close();

            return true;

        }
        catch (IOException ex) {
            //MessageManager.ShowErrorMessage(this, MessageManager.errorInOpeningFile, ex);
        }
        catch (Exception ex) {
            //MessageManager.ShowErrorMessage(this, MessageManager.errorInReadingFileFormat, ex);
        }

        return false;
    }

    /**
     * Méthode de sauvegarde du jeux d'essai.
     * On lit le jTable_Tests et on remplit le fichier en conséquence.
     * @param f
     * @return
     */
    private boolean SaveTestFile(File f){
        try {

            //Instanciation des objets de manipulation de fichier.
            FileWriter fw = new FileWriter(f);
            BufferedWriter out = new BufferedWriter(fw);

            // Récupération du modèle.
            DefaultTableModel model = (DefaultTableModel) jTable_Tests.getModel();

            // Vidage du fichier.
            out.write("");

            // Je parcours chaque ligne de mon jTable.
            for (int r = 0; r < model.getRowCount(); r++) {

                // Récupération des informations du Jtable.
                String date = (String) model.getValueAt(r, 0);
                int startFloor = (Integer) model.getValueAt(r, 1);
                int endFloor = (Integer) model.getValueAt(r, 2);
                int weight = (Integer) model.getValueAt(r, 3);
                boolean priority = (Boolean) model.getValueAt(r, 4);

                // Ecriture de ces informations dans le fichier.
                out.write(date + "  ");
                out.write(startFloor + "  ");
                out.write(endFloor + "  ");
                out.write(weight + "  ");
                out.write(priority ? "1" : "0" + "\n");
            }

            out.close();
            return true;
        }
        catch (IOException ex) {
            MessageManager.ShowErrorMessage(this, MessageManager.errorInWritingFileFormat, ex);

            return false;
        }
    }

    /**
     * Méthode de sauvegarde d'un jeu d'essai.
     * @param f fichier de destination.
     * @return
     */
    private boolean SaveQuotaFile(File f) {
        try {
            FileWriter fw = new FileWriter(f);
            BufferedWriter out = new BufferedWriter(fw);

            // Récupération du modèle.
            DefaultTableModel model = (DefaultTableModel) jTable_Quotas.getModel();

            out.write("");

            // Je parcours chaque ligne de mon jTable.
            for (int r = 0; r < model.getRowCount(); r++) {

                // Récupération des informations du Jtable.
                int startHour = (Integer)model.getValueAt(r, 0);
                int endHour = (Integer)model.getValueAt(r, 1);
                int startWeekDay = (Integer)model.getValueAt(r, 2);
                int endWeekDay = (Integer)model.getValueAt(r, 3);
                int startCallerZone = (Integer)model.getValueAt(r, 4);
                int endCallerZone = (Integer)model.getValueAt(r, 5);
                int startTargetZone = (Integer)model.getValueAt(r, 6);
                int endTargetZone = (Integer)model.getValueAt(r, 7);
                int hourlyRequestNumber = (Integer)model.getValueAt(r, 8);

                // Ecriture de ces informations dans le fichier.
                out.write(startHour + " ");
                out.write(endHour + " ");
                out.write(startWeekDay + " ");
                out.write(endWeekDay + " ");
                out.write(startCallerZone + " ");
                out.write(endCallerZone + " ");
                out.write(startTargetZone + " ");
                out.write(endTargetZone + " ");
                out.write(hourlyRequestNumber + "\n");
            }

            out.close();
            return true;

        }
        catch (IOException ex) {
            MessageManager.ShowErrorMessage(this, MessageManager.errorInWritingFileFormat, ex);
            return false;
        }
    }

    /**
     * Méthode de sauvegarde des statistiques de paramétrage.
     * @param f fichier de destination.
     * @return
     */
    private boolean SaveStatsFile(File f) {
        try {
            FileWriter fw = new FileWriter(f);
            BufferedWriter out = new BufferedWriter(fw);

            // Récupération du modèle.
            DefaultTableModel model = (DefaultTableModel) jTable_Stats.getModel();

            out.write("");

            // Je parcours chaque ligne de mon jTable.
            for (int r = 0; r < model.getRowCount(); r++) {

                // Récupération des informations du Jtable.
                int day = (Integer)model.getValueAt(r, 0);
                int hour = (Integer)model.getValueAt(r, 1);
                int floor = (Integer)model.getValueAt(r, 2);
                int requests = (Integer)model.getValueAt(r, 3);

                // Ecriture de ces informations dans le fichier.
                out.write(day + " ");
                out.write(hour + " ");
                out.write(floor + " ");
                out.write(requests + "\n");
            }

            out.close();
            return true;

        }
        catch (IOException ex) {
            MessageManager.ShowErrorMessage(this, MessageManager.errorInWritingFileFormat, ex);
            return false;
        }
    }




    /**
     * Méthode de génération des requêtes à partir du jtable de test.
     */
    private void GenerateRequestsFromTable()
    {
        // Récupération du modèle.
        DefaultTableModel model = (DefaultTableModel)jTable_Tests.getModel();

        // Je parcours chaque ligne.
        for(int r=0 ; r<model.getRowCount() ; r++)
        {
            try {

                String date = (String) model.getValueAt(r, 0);
                int startFloor = (Integer) model.getValueAt(r, 1);
                int endFloor = (Integer) model.getValueAt(r, 2);
                int weight = (Integer) model.getValueAt(r, 3);
                boolean priority = (Boolean) model.getValueAt(r, 4);

                // Ajout des requêtes dans le simulateur.
                simulatorController.addRequest(new SimpleDateFormat("MM-dd-yyyy HH:mm:ss").parse(date),
                                               startFloor,
                                               endFloor,
                                               weight,
                                               priority);
            }
            catch (ParseException ex) {
                MessageManager.ShowErrorMessage(this, MessageManager.unvalidTestTableInformation, ex);
            }
        }
    }

    /**
     * Méthode d'enregistrement des quotas dans le simulateur.
     */
    private void SaveQuotaToSimulator()
    {
        // Récupération du modèle.
        DefaultTableModel model = (DefaultTableModel)jTable_Quotas.getModel();

        // Je parcours chaque ligne de mon jTable.
            for (int r = 0; r < model.getRowCount(); r++) {

                // Récupération des informations du Jtable.
                int startHour = (Integer)model.getValueAt(r, 0);
                int endHour = (Integer)model.getValueAt(r, 1);
                int startWeekDay = (Integer) model.getValueAt(r, 2);
                int endWeekDay = (Integer)model.getValueAt(r, 3);
                int startCallerZone = (Integer)model.getValueAt(r, 4);
                int endCallerZone = (Integer)model.getValueAt(r, 5);
                int startTargetZone = (Integer)model.getValueAt(r, 6);
                int endTargetZone = (Integer)model.getValueAt(r, 7);
                int hourlyRequestNumber = (Integer)model.getValueAt(r, 8);

                if (startWeekDay == -1 || endWeekDay == -1) {
                    MessageManager.ShowInformationMessage(this, "Le quota courant possède un jour de départ ou de fin invalide.");
                }
                else{

                    // Conversion de la date en format US (dimanche = id:1)
                    startWeekDay ++;
                    startWeekDay %= 7;
                    startWeekDay ++;
                    endWeekDay ++;
                    endWeekDay %= 7;
                    endWeekDay ++;


                    // Ajout des quotas dans le simulateur.
                    simulatorController.addQuotaZone(startHour, endHour,
                                                     startWeekDay, endWeekDay,
                                                     startCallerZone, endCallerZone,
                                                     startTargetZone, endTargetZone,
                                                     hourlyRequestNumber);
                }
            }
    }

    /**
     * Méthode de chargement des statistiques de Ecospeed.
     */
    private void UpdateSimulatorStats(){
        try {

            int[][][] statistics = new int[7][24][Utils.NB_FLOORS];

            // Initialisation
            for (int i=0; i<7; i++) {
                for (int j=0; j<24; j++) {
                    for (int k=0; k<Utils.NB_FLOORS; k++) {
                        statistics[i][j][k] = 1;
                    }
                }
            }

            // Récupération du modèle.
            DefaultTableModel model = (DefaultTableModel) jTable_Stats.getModel();

            // Je parcours chaque ligne de mon jTable.
            for (int r = 0; r < model.getRowCount(); r++) {

                // Récupération des informations du Jtable.
                int day = (Integer)model.getValueAt(r, 0);
                int hour = (Integer)model.getValueAt(r, 1);
                int floor = (Integer)model.getValueAt(r, 2);
                int requests = (Integer)model.getValueAt(r, 3);

                statistics[day][hour][floor] = requests;
            }

            simulatorController.loadStatistics(statistics);
        }
        catch (Exception ex) {
            MessageManager.ShowErrorMessage(this, MessageManager.errorInLoadingStats, ex);
        }
    }




    /**
     * Méthode de connexion des DriverLift avec les Slider
     */
    public void connectLifts(Vector<DriverLift> lifts) {
        if (lifts.size()==6) {
            lifts.get(0).addObserver((MySlider)ascenseurEco_1);
            lifts.get(1).addObserver((MySlider)ascenseurEco_2);
            lifts.get(2).addObserver((MySlider)ascenseurEco_3);
            lifts.get(3).addObserver((MySlider)ascenseurEco_4);
            lifts.get(4).addObserver((MySlider)ascenseurEco_5);
            lifts.get(5).addObserver((MySlider)ascenseurEco_6);

            lifts.get(0).addObserver((ConsoLabel) jLB_ConsoEcospeed);
            lifts.get(1).addObserver((ConsoLabel) jLB_ConsoEcospeed);
            lifts.get(2).addObserver((ConsoLabel) jLB_ConsoEcospeed);
            lifts.get(3).addObserver((ConsoLabel) jLB_ConsoEcospeed);
            lifts.get(4).addObserver((ConsoLabel) jLB_ConsoEcospeed);
            lifts.get(5).addObserver((ConsoLabel) jLB_ConsoEcospeed);
        }
    }

    /**
     * Méthode connexion des ascenseurs standard.
     * @param lifts
     */
    public void connectStandardLifts(Vector <StandardDriverLift> lifts){
        if (lifts.size()==6) {
            lifts.get(0).addObserver((MySlider)ascenseurStd_1);
            lifts.get(1).addObserver((MySlider)ascenseurStd_2);
            lifts.get(2).addObserver((MySlider)ascenseurStd_3);
            lifts.get(3).addObserver((MySlider)ascenseurStd_4);
            lifts.get(4).addObserver((MySlider)ascenseurStd_5);
            lifts.get(5).addObserver((MySlider)ascenseurStd_6);

            lifts.get(0).addObserver((ConsoLabel) jLB_ConsoStandard);
            lifts.get(1).addObserver((ConsoLabel) jLB_ConsoStandard);
            lifts.get(2).addObserver((ConsoLabel) jLB_ConsoStandard);
            lifts.get(3).addObserver((ConsoLabel) jLB_ConsoStandard);
            lifts.get(4).addObserver((ConsoLabel) jLB_ConsoStandard);
            lifts.get(5).addObserver((ConsoLabel) jLB_ConsoStandard);
        }
    }

    /**
     * Connexion des labels de l'ihm au simulateur.
     */
    public void connectSimulator()
    {
        simulatorController.addObserver((MyLabel)jLB_SimulationDate);
        simulatorController.addObserver((SpeedLabel)jLB_SimulationSpeed);
	simulatorController.addObserver((NbDemandeLabel)jLB_ProcessedRequestsEcospeed);
	simulatorController.addObserver((NbDemandeLabel)jLB_ProcessedRequestsStandard);

	simulatorController.addObserver((DelayLabel)jLB_WaitingTimeEcospeed);
	simulatorController.addObserver((DelayLabel)jLB_WaitingTimeStandard);
    }

    /**
     * Méthode de connexion du panel alarme à l'alarme.
     * @param alarm
     */
    public void connectAlarm(Alarme alarm)
    {
        if(alarm != null){
            alarm.addObserver((AlarmPanel)jPanel_Alarm);
        }
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jTabbedPane1 = new javax.swing.JTabbedPane();
        jLayeredPane_simulation = new javax.swing.JLayeredPane();
        Panel_Informations = new javax.swing.JPanel();
        jPanel5 = new javax.swing.JPanel();
        jLabel8 = new javax.swing.JLabel();
        jPanel6 = new javax.swing.JPanel();
        jLabel10 = new javax.swing.JLabel();
        jLabel19 = new javax.swing.JLabel();
        jPanel8 = new javax.swing.JPanel();
        jLabel14 = new javax.swing.JLabel();
        jLabel16 = new javax.swing.JLabel();
        jPanel3 = new javax.swing.JPanel();
        jLabel17 = new javax.swing.JLabel();
        jLabel1 = new javax.swing.JLabel();
        jLabel39 = new javax.swing.JLabel();
        jLabel40 = new javax.swing.JLabel();
        jLabel41 = new javax.swing.JLabel();
        jLabel42 = new javax.swing.JLabel();
        Panel_Ecospeed = new javax.swing.JPanel();
        ascenseurEco_1 = new MySlider();
        ascenseurEco_2 = new MySlider();
        ascenseurEco_3 = new MySlider();
        ascenseurEco_4 = new MySlider();
        ascenseurEco_5 = new MySlider();
        ascenseurEco_6 = new MySlider();
        jPanel2 = new javax.swing.JPanel();
        jPanel4 = new javax.swing.JPanel();
        jPanel7 = new javax.swing.JPanel();
        jPanel9 = new javax.swing.JPanel();
        jPanel10 = new javax.swing.JPanel();
        jLabel13 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLB_ConsoEcospeed = new IHMSimulator.ConsoLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel35 = new javax.swing.JLabel();
        jLB_WaitingTimeEcospeed = new DelayLabel(true);
        jLabel18 = new javax.swing.JLabel();
        jLabel34 = new javax.swing.JLabel();
        jLB_ProcessedRequestsEcospeed = new NbDemandeLabel(true);
        Panel_Standard = new javax.swing.JPanel();
        ascenseurStd_1 = new MySlider();
        ascenseurStd_2 = new MySlider();
        ascenseurStd_3 = new MySlider();
        ascenseurStd_4 = new MySlider();
        ascenseurStd_5 = new MySlider();
        ascenseurStd_6 = new MySlider();
        jPanel11 = new javax.swing.JPanel();
        jPanel12 = new javax.swing.JPanel();
        jPanel13 = new javax.swing.JPanel();
        jPanel14 = new javax.swing.JPanel();
        jPanel15 = new javax.swing.JPanel();
        jLabel20 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        jLB_ConsoStandard = new IHMSimulator.ConsoLabel();
        jLabel33 = new javax.swing.JLabel();
        jLabel36 = new javax.swing.JLabel();
        jLB_WaitingTimeStandard = new DelayLabel(false);
        jLabel37 = new javax.swing.JLabel();
        jLabel38 = new javax.swing.JLabel();
        jLB_ProcessedRequestsStandard = new NbDemandeLabel(false);
        jBtn_AddDirectRequest = new javax.swing.JButton();
        jBtn_SaveSimulation = new javax.swing.JButton();
        jPanel_jeuxEssais = new javax.swing.JPanel();
        JBtn_LoadTestFile = new javax.swing.JButton();
        jTF_TestName = new javax.swing.JTextField();
        jButton_DeleteRequest = new javax.swing.JButton();
        jButton_ClearAllRequest = new javax.swing.JButton();
        JBtn_SaveTestFile = new javax.swing.JButton();
        jLabel15 = new javax.swing.JLabel();
        jScrollPane2 = new javax.swing.JScrollPane();
        jTable_Tests = new javax.swing.JTable();
        jBtn_AddRequest = new javax.swing.JButton();
        jPanel_statistiques = new javax.swing.JPanel();
        JBtn_LoadStatsFile = new javax.swing.JButton();
        JBtn_SaveStatsFile = new javax.swing.JButton();
        jTextField_QuotaName = new javax.swing.JTextField();
        jLabel11 = new javax.swing.JLabel();
        jBtn_AddQuota = new javax.swing.JButton();
        jBtn_DeleteQuota = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTable_Quotas = new javax.swing.JTable();
        jBtn_ClearAllQuotas = new javax.swing.JButton();
        jPanel_Param = new javax.swing.JPanel();
        jLabel4 = new javax.swing.JLabel();
        jLayeredPane1 = new javax.swing.JLayeredPane();
        jLabel25 = new javax.swing.JLabel();
        jTF_ConsumptionMovingDown = new javax.swing.JTextField();
        jLabel26 = new javax.swing.JLabel();
        jLabel43 = new javax.swing.JLabel();
        jTF_ConsumptionMovingUp = new javax.swing.JTextField();
        jLabel44 = new javax.swing.JLabel();
        jLabel21 = new javax.swing.JLabel();
        jScrollPane3 = new javax.swing.JScrollPane();
        jTable_Stats = new javax.swing.JTable();
        jBtn_SaveStats = new javax.swing.JButton();
        jBtn_LoadStats = new javax.swing.JButton();
        jTF_StatsFile = new javax.swing.JTextField();
        jBtn_UpdateStats = new javax.swing.JButton();
        jPanel_Controles = new javax.swing.JPanel();
        jLP_Controls = new javax.swing.JLayeredPane();
        jPanel_Alarm = new AlarmPanel();
        jLabel6 = new javax.swing.JLabel();
        jPanel_SimulatorControls = new javax.swing.JPanel();
        jBtn_SimulationStop = new javax.swing.JButton();
        jBtn_DivideSpeed = new javax.swing.JButton();
        jBtn_SimulationStart = new javax.swing.JButton();
        jBtn_MultiplySpeed = new javax.swing.JButton();
        jBtn_SimulationAlerte = new javax.swing.JButton();
        jBtn_Reset = new javax.swing.JButton();
        jLabel7 = new javax.swing.JLabel();
        jLB_SimulationDate = new MyLabel();
        jLabel9 = new javax.swing.JLabel();
        jLB_SimulationSpeed = new SpeedLabel();
        jBtn_UpdateDate = new javax.swing.JButton();
        jBtn_ChangeLookAndFeel = new javax.swing.JButton();
        jCB_SimulationQuotas = new javax.swing.JCheckBox();
        jCB_SimulationTests = new javax.swing.JCheckBox();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Ecospeed - Simulator");
        setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));

        Panel_Informations.setOpaque(false);
        Panel_Informations.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jPanel5.setBackground(new java.awt.Color(237, 150, 64));
        jPanel5.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        jPanel5.setPreferredSize(new java.awt.Dimension(101, 76));

        jLabel8.setFont(new java.awt.Font("DejaVu Sans", 1, 13));
        jLabel8.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel8.setText("Hotel");

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jLabel8, javax.swing.GroupLayout.DEFAULT_SIZE, 99, Short.MAX_VALUE)
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jLabel8, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 58, Short.MAX_VALUE)
        );

        Panel_Informations.add(jPanel5, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 9, -1, 60));

        jPanel6.setBackground(new java.awt.Color(105, 111, 240));
        jPanel6.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        jPanel6.setPreferredSize(new java.awt.Dimension(101, 144));

        jLabel10.setFont(new java.awt.Font("DejaVu Sans", 1, 13));
        jLabel10.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel10.setText("Multi -");

        jLabel19.setFont(new java.awt.Font("DejaVu Sans", 1, 13));
        jLabel19.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel19.setText("Nationale");

        javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
        jPanel6.setLayout(jPanel6Layout);
        jPanel6Layout.setHorizontalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jLabel19, javax.swing.GroupLayout.DEFAULT_SIZE, 99, Short.MAX_VALUE)
            .addComponent(jLabel10, javax.swing.GroupLayout.DEFAULT_SIZE, 99, Short.MAX_VALUE)
        );
        jPanel6Layout.setVerticalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel6Layout.createSequentialGroup()
                .addGap(49, 49, 49)
                .addComponent(jLabel10)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 8, Short.MAX_VALUE)
                .addComponent(jLabel19)
                .addGap(57, 57, 57))
        );

        Panel_Informations.add(jPanel6, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 68, -1, 150));

        jPanel8.setBackground(new java.awt.Color(124, 214, 147));
        jPanel8.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));

        jLabel14.setFont(new java.awt.Font("DejaVu Sans", 1, 13));
        jLabel14.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel14.setText("Bureaux");

        jLabel16.setFont(new java.awt.Font("Tahoma", 1, 12));
        jLabel16.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel16.setText("indépendants");

        javax.swing.GroupLayout jPanel8Layout = new javax.swing.GroupLayout(jPanel8);
        jPanel8.setLayout(jPanel8Layout);
        jPanel8Layout.setHorizontalGroup(
            jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jLabel14, javax.swing.GroupLayout.DEFAULT_SIZE, 99, Short.MAX_VALUE)
            .addComponent(jLabel16, javax.swing.GroupLayout.DEFAULT_SIZE, 99, Short.MAX_VALUE)
        );
        jPanel8Layout.setVerticalGroup(
            jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel8Layout.createSequentialGroup()
                .addGap(69, 69, 69)
                .addComponent(jLabel14)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel16, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(93, Short.MAX_VALUE))
        );

        Panel_Informations.add(jPanel8, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 217, -1, 210));

        jPanel3.setBackground(new java.awt.Color(206, 221, 102));
        jPanel3.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));

        jLabel17.setFont(new java.awt.Font("Tahoma", 1, 12));
        jLabel17.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel17.setText("Sous-sol");

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jLabel17, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 99, Short.MAX_VALUE)
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel17)
                .addContainerGap(31, Short.MAX_VALUE))
        );

        Panel_Informations.add(jPanel3, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 426, -1, 60));

        jLabel1.setText("-4");
        Panel_Informations.add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(15, 480, -1, -1));

        jLabel39.setText("0");
        Panel_Informations.add(jLabel39, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 420, 10, -1));

        jLabel40.setText("20");
        Panel_Informations.add(jLabel40, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 220, -1, -1));

        jLabel41.setText("35");
        Panel_Informations.add(jLabel41, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 70, -1, -1));

        jLabel42.setText("40");
        Panel_Informations.add(jLabel42, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 10, -1, -1));

        Panel_Informations.setBounds(10, 11, 150, 500);
        jLayeredPane_simulation.add(Panel_Informations, javax.swing.JLayeredPane.DEFAULT_LAYER);

        Panel_Ecospeed.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        Panel_Ecospeed.setOpaque(false);
        Panel_Ecospeed.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        ascenseurEco_1.setMaximum(EcoSpeed.Utils.NB_FLOORS-(1+EcoSpeed.Utils.NB_UNDERGROUND));
        ascenseurEco_1.setMinimum(-EcoSpeed.Utils.NB_UNDERGROUND);
        ascenseurEco_1.setOrientation(javax.swing.JSlider.VERTICAL);
        ascenseurEco_1.setPaintTicks(true);
        ascenseurEco_1.setValue(0);
        ascenseurEco_1.setEnabled(false);
        ascenseurEco_1.setName("Slider1"); // NOI18N
        Panel_Ecospeed.add(ascenseurEco_1, new org.netbeans.lib.awtextra.AbsoluteConstraints(5, 0, 30, 470));

        ascenseurEco_2.setMaximum(EcoSpeed.Utils.NB_FLOORS-(1+EcoSpeed.Utils.NB_UNDERGROUND));
        ascenseurEco_2.setMinimum(-EcoSpeed.Utils.NB_UNDERGROUND);
        ascenseurEco_2.setOrientation(javax.swing.JSlider.VERTICAL);
        ascenseurEco_2.setPaintTicks(true);
        ascenseurEco_2.setValue(0);
        ascenseurEco_2.setEnabled(false);
        Panel_Ecospeed.add(ascenseurEco_2, new org.netbeans.lib.awtextra.AbsoluteConstraints(39, 0, -1, 470));

        ascenseurEco_3.setMaximum(EcoSpeed.Utils.NB_FLOORS-(1+EcoSpeed.Utils.NB_UNDERGROUND));
        ascenseurEco_3.setMinimum(-EcoSpeed.Utils.NB_UNDERGROUND);
        ascenseurEco_3.setOrientation(javax.swing.JSlider.VERTICAL);
        ascenseurEco_3.setPaintTicks(true);
        ascenseurEco_3.setValue(0);
        ascenseurEco_3.setEnabled(false);
        Panel_Ecospeed.add(ascenseurEco_3, new org.netbeans.lib.awtextra.AbsoluteConstraints(77, 0, -1, 470));

        ascenseurEco_4.setMaximum(EcoSpeed.Utils.NB_FLOORS-(1+EcoSpeed.Utils.NB_UNDERGROUND));
        ascenseurEco_4.setMinimum(-EcoSpeed.Utils.NB_UNDERGROUND);
        ascenseurEco_4.setOrientation(javax.swing.JSlider.VERTICAL);
        ascenseurEco_4.setPaintTicks(true);
        ascenseurEco_4.setValue(0);
        ascenseurEco_4.setEnabled(false);
        Panel_Ecospeed.add(ascenseurEco_4, new org.netbeans.lib.awtextra.AbsoluteConstraints(115, 0, 30, 470));

        ascenseurEco_5.setMaximum(EcoSpeed.Utils.NB_FLOORS-(1+EcoSpeed.Utils.NB_UNDERGROUND));
        ascenseurEco_5.setMinimum(-EcoSpeed.Utils.NB_UNDERGROUND);
        ascenseurEco_5.setOrientation(javax.swing.JSlider.VERTICAL);
        ascenseurEco_5.setPaintTicks(true);
        ascenseurEco_5.setValue(0);
        ascenseurEco_5.setAlignmentX(0.0F);
        ascenseurEco_5.setAlignmentY(0.0F);
        ascenseurEco_5.setAutoscrolls(true);
        ascenseurEco_5.setEnabled(false);
        Panel_Ecospeed.add(ascenseurEco_5, new org.netbeans.lib.awtextra.AbsoluteConstraints(155, 0, -1, 470));

        ascenseurEco_6.setMaximum(EcoSpeed.Utils.NB_FLOORS-(1+EcoSpeed.Utils.NB_UNDERGROUND));
        ascenseurEco_6.setMinimum(-EcoSpeed.Utils.NB_UNDERGROUND);
        ascenseurEco_6.setOrientation(javax.swing.JSlider.VERTICAL);
        ascenseurEco_6.setPaintTicks(true);
        ascenseurEco_6.setValue(0);
        ascenseurEco_6.setEnabled(false);
        Panel_Ecospeed.add(ascenseurEco_6, new org.netbeans.lib.awtextra.AbsoluteConstraints(195, 0, -1, 470));

        jPanel2.setBackground(new java.awt.Color(237, 150, 64));
        jPanel2.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        jPanel2.setPreferredSize(new java.awt.Dimension(220, 70));

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 228, Short.MAX_VALUE)
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 58, Short.MAX_VALUE)
        );

        Panel_Ecospeed.add(jPanel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, 230, 60));

        jPanel4.setBackground(new java.awt.Color(105, 111, 240));
        jPanel4.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        jPanel4.setPreferredSize(new java.awt.Dimension(220, 164));

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 228, Short.MAX_VALUE)
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 148, Short.MAX_VALUE)
        );

        Panel_Ecospeed.add(jPanel4, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 59, 230, 150));

        jPanel7.setBackground(new java.awt.Color(124, 214, 147));
        jPanel7.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        jPanel7.setPreferredSize(new java.awt.Dimension(220, 230));

        javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7);
        jPanel7.setLayout(jPanel7Layout);
        jPanel7Layout.setHorizontalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 228, Short.MAX_VALUE)
        );
        jPanel7Layout.setVerticalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 208, Short.MAX_VALUE)
        );

        Panel_Ecospeed.add(jPanel7, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 208, 230, 210));

        jPanel9.setBackground(new java.awt.Color(206, 221, 102));
        jPanel9.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));

        javax.swing.GroupLayout jPanel9Layout = new javax.swing.GroupLayout(jPanel9);
        jPanel9.setLayout(jPanel9Layout);
        jPanel9Layout.setHorizontalGroup(
            jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 228, Short.MAX_VALUE)
        );
        jPanel9Layout.setVerticalGroup(
            jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 58, Short.MAX_VALUE)
        );

        Panel_Ecospeed.add(jPanel9, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 417, 230, 60));

        jPanel10.setBackground(java.awt.Color.white);
        jPanel10.setOpaque(false);
        jPanel10.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jLabel13.setFont(new java.awt.Font("DejaVu Sans", 1, 16));
        jLabel13.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel13.setText("Système Ecospeed");
        jPanel10.add(jLabel13, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 10, 220, -1));

        jLabel3.setText("Consommation :");
        jPanel10.add(jLabel3, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 40, 120, 20));

        jLB_ConsoEcospeed.setFont(new java.awt.Font("DejaVu Sans", 1, 13));
        jLB_ConsoEcospeed.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLB_ConsoEcospeed.setText("0");
        jPanel10.add(jLB_ConsoEcospeed, new org.netbeans.lib.awtextra.AbsoluteConstraints(100, 40, 70, 20));

        jLabel5.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel5.setText("KWatts");
        jPanel10.add(jLabel5, new org.netbeans.lib.awtextra.AbsoluteConstraints(170, 40, 50, 20));

        jLabel35.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel35.setText("s");
        jPanel10.add(jLabel35, new org.netbeans.lib.awtextra.AbsoluteConstraints(190, 60, 20, 20));

        jLB_WaitingTimeEcospeed.setFont(new java.awt.Font("DejaVu Sans", 1, 13));
        jLB_WaitingTimeEcospeed.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLB_WaitingTimeEcospeed.setText("0");
        jPanel10.add(jLB_WaitingTimeEcospeed, new org.netbeans.lib.awtextra.AbsoluteConstraints(120, 60, 50, -1));

        jLabel18.setText("Temps d'attente :");
        jPanel10.add(jLabel18, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 60, 120, 20));

        jLabel34.setText("Demandes traitées :");
        jPanel10.add(jLabel34, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 80, 120, 20));

        jLB_ProcessedRequestsEcospeed.setFont(new java.awt.Font("DejaVu Sans", 1, 13));
        jLB_ProcessedRequestsEcospeed.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLB_ProcessedRequestsEcospeed.setText("0");
        jPanel10.add(jLB_ProcessedRequestsEcospeed, new org.netbeans.lib.awtextra.AbsoluteConstraints(120, 80, 50, -1));

        Panel_Ecospeed.add(jPanel10, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 480, 230, -1));

        Panel_Ecospeed.setBounds(220, 20, 230, 590);
        jLayeredPane_simulation.add(Panel_Ecospeed, javax.swing.JLayeredPane.DEFAULT_LAYER);

        Panel_Standard.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        Panel_Standard.setOpaque(false);
        Panel_Standard.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        ascenseurStd_1.setMaximum(EcoSpeed.Utils.NB_FLOORS-(1+EcoSpeed.Utils.NB_UNDERGROUND));
        ascenseurStd_1.setMinimum(-EcoSpeed.Utils.NB_UNDERGROUND);
        ascenseurStd_1.setOrientation(javax.swing.JSlider.VERTICAL);
        ascenseurStd_1.setPaintTicks(true);
        ascenseurStd_1.setValue(0);
        ascenseurStd_1.setEnabled(false);
        ascenseurStd_1.setName("Slider1"); // NOI18N
        Panel_Standard.add(ascenseurStd_1, new org.netbeans.lib.awtextra.AbsoluteConstraints(5, 0, 30, 470));

        ascenseurStd_2.setMaximum(EcoSpeed.Utils.NB_FLOORS-(1+EcoSpeed.Utils.NB_UNDERGROUND));
        ascenseurStd_2.setMinimum(-EcoSpeed.Utils.NB_UNDERGROUND);
        ascenseurStd_2.setOrientation(javax.swing.JSlider.VERTICAL);
        ascenseurStd_2.setPaintTicks(true);
        ascenseurStd_2.setValue(0);
        ascenseurStd_2.setEnabled(false);
        Panel_Standard.add(ascenseurStd_2, new org.netbeans.lib.awtextra.AbsoluteConstraints(39, 0, -1, 470));

        ascenseurStd_3.setMaximum(EcoSpeed.Utils.NB_FLOORS-(1+EcoSpeed.Utils.NB_UNDERGROUND));
        ascenseurStd_3.setMinimum(-EcoSpeed.Utils.NB_UNDERGROUND);
        ascenseurStd_3.setOrientation(javax.swing.JSlider.VERTICAL);
        ascenseurStd_3.setPaintTicks(true);
        ascenseurStd_3.setValue(0);
        ascenseurStd_3.setEnabled(false);
        Panel_Standard.add(ascenseurStd_3, new org.netbeans.lib.awtextra.AbsoluteConstraints(77, 0, -1, 470));

        ascenseurStd_4.setMaximum(EcoSpeed.Utils.NB_FLOORS-(1+EcoSpeed.Utils.NB_UNDERGROUND));
        ascenseurStd_4.setMinimum(-EcoSpeed.Utils.NB_UNDERGROUND);
        ascenseurStd_4.setOrientation(javax.swing.JSlider.VERTICAL);
        ascenseurStd_4.setPaintTicks(true);
        ascenseurStd_4.setValue(0);
        ascenseurStd_4.setEnabled(false);
        Panel_Standard.add(ascenseurStd_4, new org.netbeans.lib.awtextra.AbsoluteConstraints(115, 0, 30, 470));

        ascenseurStd_5.setMaximum(EcoSpeed.Utils.NB_FLOORS-(1+EcoSpeed.Utils.NB_UNDERGROUND));
        ascenseurStd_5.setMinimum(-EcoSpeed.Utils.NB_UNDERGROUND);
        ascenseurStd_5.setOrientation(javax.swing.JSlider.VERTICAL);
        ascenseurStd_5.setPaintTicks(true);
        ascenseurStd_5.setValue(0);
        ascenseurStd_5.setAlignmentX(0.0F);
        ascenseurStd_5.setAlignmentY(0.0F);
        ascenseurStd_5.setAutoscrolls(true);
        ascenseurStd_5.setEnabled(false);
        Panel_Standard.add(ascenseurStd_5, new org.netbeans.lib.awtextra.AbsoluteConstraints(155, 0, -1, 470));

        ascenseurStd_6.setMaximum(EcoSpeed.Utils.NB_FLOORS-(1+EcoSpeed.Utils.NB_UNDERGROUND));
        ascenseurStd_6.setMinimum(-EcoSpeed.Utils.NB_UNDERGROUND);
        ascenseurStd_6.setOrientation(javax.swing.JSlider.VERTICAL);
        ascenseurStd_6.setPaintTicks(true);
        ascenseurStd_6.setValue(0);
        ascenseurStd_6.setEnabled(false);
        Panel_Standard.add(ascenseurStd_6, new org.netbeans.lib.awtextra.AbsoluteConstraints(195, 0, -1, 470));

        jPanel11.setBackground(new java.awt.Color(237, 150, 64));
        jPanel11.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        jPanel11.setPreferredSize(new java.awt.Dimension(220, 70));

        javax.swing.GroupLayout jPanel11Layout = new javax.swing.GroupLayout(jPanel11);
        jPanel11.setLayout(jPanel11Layout);
        jPanel11Layout.setHorizontalGroup(
            jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 228, Short.MAX_VALUE)
        );
        jPanel11Layout.setVerticalGroup(
            jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 58, Short.MAX_VALUE)
        );

        Panel_Standard.add(jPanel11, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, 230, 60));

        jPanel12.setBackground(new java.awt.Color(105, 111, 240));
        jPanel12.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        jPanel12.setPreferredSize(new java.awt.Dimension(220, 164));

        javax.swing.GroupLayout jPanel12Layout = new javax.swing.GroupLayout(jPanel12);
        jPanel12.setLayout(jPanel12Layout);
        jPanel12Layout.setHorizontalGroup(
            jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 228, Short.MAX_VALUE)
        );
        jPanel12Layout.setVerticalGroup(
            jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 148, Short.MAX_VALUE)
        );

        Panel_Standard.add(jPanel12, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 59, 230, 150));

        jPanel13.setBackground(new java.awt.Color(124, 214, 147));
        jPanel13.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        jPanel13.setPreferredSize(new java.awt.Dimension(220, 230));

        javax.swing.GroupLayout jPanel13Layout = new javax.swing.GroupLayout(jPanel13);
        jPanel13.setLayout(jPanel13Layout);
        jPanel13Layout.setHorizontalGroup(
            jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 228, Short.MAX_VALUE)
        );
        jPanel13Layout.setVerticalGroup(
            jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 208, Short.MAX_VALUE)
        );

        Panel_Standard.add(jPanel13, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 208, 230, 210));

        jPanel14.setBackground(new java.awt.Color(206, 221, 102));
        jPanel14.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));

        javax.swing.GroupLayout jPanel14Layout = new javax.swing.GroupLayout(jPanel14);
        jPanel14.setLayout(jPanel14Layout);
        jPanel14Layout.setHorizontalGroup(
            jPanel14Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 228, Short.MAX_VALUE)
        );
        jPanel14Layout.setVerticalGroup(
            jPanel14Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 58, Short.MAX_VALUE)
        );

        Panel_Standard.add(jPanel14, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 417, 230, 60));

        jPanel15.setBackground(java.awt.Color.white);
        jPanel15.setOpaque(false);
        jPanel15.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jLabel20.setFont(new java.awt.Font("DejaVu Sans", 1, 16));
        jLabel20.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel20.setText("Système Standard");
        jPanel15.add(jLabel20, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 10, 220, -1));

        jLabel12.setText("Consommation :");
        jPanel15.add(jLabel12, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 40, 120, 20));

        jLB_ConsoStandard.setFont(new java.awt.Font("DejaVu Sans", 1, 13));
        jLB_ConsoStandard.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLB_ConsoStandard.setText("0");
        jPanel15.add(jLB_ConsoStandard, new org.netbeans.lib.awtextra.AbsoluteConstraints(100, 40, 70, 20));

        jLabel33.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel33.setText("KWatts");
        jPanel15.add(jLabel33, new org.netbeans.lib.awtextra.AbsoluteConstraints(170, 40, 50, 20));

        jLabel36.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel36.setText("s");
        jPanel15.add(jLabel36, new org.netbeans.lib.awtextra.AbsoluteConstraints(190, 60, 20, 20));

        jLB_WaitingTimeStandard.setFont(new java.awt.Font("DejaVu Sans", 1, 13));
        jLB_WaitingTimeStandard.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLB_WaitingTimeStandard.setText("0");
        jPanel15.add(jLB_WaitingTimeStandard, new org.netbeans.lib.awtextra.AbsoluteConstraints(120, 60, 50, -1));

        jLabel37.setText("Temps d'attente :");
        jPanel15.add(jLabel37, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 60, 120, 20));

        jLabel38.setText("Demandes traitées :");
        jPanel15.add(jLabel38, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 80, 120, 20));

        jLB_ProcessedRequestsStandard.setFont(new java.awt.Font("DejaVu Sans", 1, 13));
        jLB_ProcessedRequestsStandard.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLB_ProcessedRequestsStandard.setText("0");
        jPanel15.add(jLB_ProcessedRequestsStandard, new org.netbeans.lib.awtextra.AbsoluteConstraints(120, 80, 50, -1));

        Panel_Standard.add(jPanel15, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 480, 230, -1));

        Panel_Standard.setBounds(510, 20, 230, 590);
        jLayeredPane_simulation.add(Panel_Standard, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jBtn_AddDirectRequest.setText("+");
        jBtn_AddDirectRequest.setToolTipText("Ajout d'un nouvelle requête");
        jBtn_AddDirectRequest.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBtn_AddDirectRequestActionPerformed(evt);
            }
        });
        jBtn_AddDirectRequest.setBounds(60, 510, 80, 40);
        jLayeredPane_simulation.add(jBtn_AddDirectRequest, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jBtn_SaveSimulation.setText("SAVE");
        jBtn_SaveSimulation.setToolTipText("Sauvegarde des requêtes exécutées");
        jBtn_SaveSimulation.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBtn_SaveSimulationActionPerformed(evt);
            }
        });
        jBtn_SaveSimulation.setBounds(60, 550, 80, 40);
        jLayeredPane_simulation.add(jBtn_SaveSimulation, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jTabbedPane1.addTab("Simulation", jLayeredPane_simulation);

        jPanel_jeuxEssais.setOpaque(false);
        jPanel_jeuxEssais.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        JBtn_LoadTestFile.setText("Chargement d'un fichier de jeux d'essais");
        JBtn_LoadTestFile.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                JBtn_LoadTestFileActionPerformed(evt);
            }
        });
        jPanel_jeuxEssais.add(JBtn_LoadTestFile, new org.netbeans.lib.awtextra.AbsoluteConstraints(80, 110, 270, -1));

        jTF_TestName.setEnabled(false);
        jTF_TestName.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTF_TestNameActionPerformed(evt);
            }
        });
        jPanel_jeuxEssais.add(jTF_TestName, new org.netbeans.lib.awtextra.AbsoluteConstraints(360, 120, 330, -1));

        jButton_DeleteRequest.setText("Supprimer");
        jButton_DeleteRequest.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton_DeleteRequestActionPerformed(evt);
            }
        });
        jPanel_jeuxEssais.add(jButton_DeleteRequest, new org.netbeans.lib.awtextra.AbsoluteConstraints(350, 580, 120, -1));

        jButton_ClearAllRequest.setText("Effacer tout");
        jButton_ClearAllRequest.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton_ClearAllRequestActionPerformed(evt);
            }
        });
        jPanel_jeuxEssais.add(jButton_ClearAllRequest, new org.netbeans.lib.awtextra.AbsoluteConstraints(480, 580, 120, -1));

        JBtn_SaveTestFile.setText("Sauvegarder");
        JBtn_SaveTestFile.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                JBtn_SaveTestFileActionPerformed(evt);
            }
        });
        jPanel_jeuxEssais.add(JBtn_SaveTestFile, new org.netbeans.lib.awtextra.AbsoluteConstraints(80, 130, 270, -1));

        jLabel15.setFont(new java.awt.Font("Tahoma", 1, 14));
        jLabel15.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel15.setText("Gestion des jeux d'essais");
        jPanel_jeuxEssais.add(jLabel15, new org.netbeans.lib.awtextra.AbsoluteConstraints(310, 30, -1, -1));

        jTable_Tests.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Date", "Etage d'appel", "Etage de destination", "Poids (kg)", "Urgence"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.Integer.class, java.lang.Integer.class, java.lang.Integer.class, java.lang.Boolean.class
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }
        });
        jScrollPane2.setViewportView(jTable_Tests);
        jTable_Tests.getColumnModel().getColumn(1).setResizable(false);
        jTable_Tests.getColumnModel().getColumn(2).setPreferredWidth(100);
        jTable_Tests.getColumnModel().getColumn(3).setResizable(false);
        jTable_Tests.getColumnModel().getColumn(4).setResizable(false);

        jPanel_jeuxEssais.add(jScrollPane2, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 167, 770, 410));

        jBtn_AddRequest.setText("Ajouter");
        jBtn_AddRequest.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBtn_AddRequestActionPerformed(evt);
            }
        });
        jPanel_jeuxEssais.add(jBtn_AddRequest, new org.netbeans.lib.awtextra.AbsoluteConstraints(220, 580, 120, -1));

        jTabbedPane1.addTab("Jeux d'essais", jPanel_jeuxEssais);

        jPanel_statistiques.setOpaque(false);
        jPanel_statistiques.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        JBtn_LoadStatsFile.setText("Chargement d'un fichier de quotas");
        JBtn_LoadStatsFile.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                JBtn_LoadStatsFileActionPerformed(evt);
            }
        });
        jPanel_statistiques.add(JBtn_LoadStatsFile, new org.netbeans.lib.awtextra.AbsoluteConstraints(80, 110, 270, -1));

        JBtn_SaveStatsFile.setText("Sauvegarder");
        JBtn_SaveStatsFile.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                JBtn_SaveStatsFileActionPerformed(evt);
            }
        });
        jPanel_statistiques.add(JBtn_SaveStatsFile, new org.netbeans.lib.awtextra.AbsoluteConstraints(80, 130, 270, -1));

        jTextField_QuotaName.setEnabled(false);
        jPanel_statistiques.add(jTextField_QuotaName, new org.netbeans.lib.awtextra.AbsoluteConstraints(360, 120, 330, -1));

        jLabel11.setFont(new java.awt.Font("Tahoma", 1, 14));
        jLabel11.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel11.setText("Gestion des quotas");
        jPanel_statistiques.add(jLabel11, new org.netbeans.lib.awtextra.AbsoluteConstraints(280, 10, 230, -1));

        jBtn_AddQuota.setText("Ajouter");
        jBtn_AddQuota.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBtn_AddQuotaActionPerformed(evt);
            }
        });
        jPanel_statistiques.add(jBtn_AddQuota, new org.netbeans.lib.awtextra.AbsoluteConstraints(190, 580, 130, -1));

        jBtn_DeleteQuota.setText("Supprimer");
        jBtn_DeleteQuota.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBtn_DeleteQuotaActionPerformed(evt);
            }
        });
        jPanel_statistiques.add(jBtn_DeleteQuota, new org.netbeans.lib.awtextra.AbsoluteConstraints(330, 580, 140, -1));

        jTable_Quotas.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "heure début", "heure fin", "jour début", "jour fin", "étage dde début", "étage dde fin", "étage dest début", "étage dest fin", "demandes"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.Integer.class, java.lang.Integer.class, java.lang.Integer.class, java.lang.Integer.class, java.lang.Integer.class, java.lang.Integer.class, java.lang.Integer.class, java.lang.Integer.class, java.lang.Integer.class
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }
        });
        jScrollPane1.setViewportView(jTable_Quotas);
        jTable_Quotas.getColumnModel().getColumn(0).setPreferredWidth(70);
        jTable_Quotas.getColumnModel().getColumn(1).setPreferredWidth(45);
        jTable_Quotas.getColumnModel().getColumn(2).setPreferredWidth(50);
        jTable_Quotas.getColumnModel().getColumn(3).setPreferredWidth(35);
        jTable_Quotas.getColumnModel().getColumn(4).setPreferredWidth(100);
        jTable_Quotas.getColumnModel().getColumn(5).setPreferredWidth(80);
        jTable_Quotas.getColumnModel().getColumn(6).setPreferredWidth(100);
        jTable_Quotas.getColumnModel().getColumn(7).setPreferredWidth(80);
        jTable_Quotas.getColumnModel().getColumn(8).setPreferredWidth(50);

        jPanel_statistiques.add(jScrollPane1, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 170, 770, 410));

        jBtn_ClearAllQuotas.setText("Effacer tout");
        jBtn_ClearAllQuotas.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBtn_ClearAllQuotasActionPerformed(evt);
            }
        });
        jPanel_statistiques.add(jBtn_ClearAllQuotas, new org.netbeans.lib.awtextra.AbsoluteConstraints(480, 580, 130, -1));

        jTabbedPane1.addTab("Quotas", jPanel_statistiques);

        jPanel_Param.setOpaque(false);
        jPanel_Param.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jLabel4.setFont(new java.awt.Font("Tahoma", 1, 14));
        jLabel4.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel4.setText("Gestion du paramétrage du simulateur");
        jPanel_Param.add(jLabel4, new org.netbeans.lib.awtextra.AbsoluteConstraints(230, 0, 360, -1));

        jLabel25.setText("Consommation de descente d'un étage :");
        jLabel25.setBounds(20, 40, 280, 25);
        jLayeredPane1.add(jLabel25, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jTF_ConsumptionMovingDown.setText("750");
        jTF_ConsumptionMovingDown.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                jTF_ConsumptionMovingDownFocusLost(evt);
            }
        });
        jTF_ConsumptionMovingDown.setBounds(320, 40, 60, 25);
        jLayeredPane1.add(jTF_ConsumptionMovingDown, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel26.setText("WATTS");
        jLabel26.setBounds(400, 40, 60, 25);
        jLayeredPane1.add(jLabel26, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel43.setText("Consommation de montée d'un étage :");
        jLabel43.setBounds(20, 10, 280, 25);
        jLayeredPane1.add(jLabel43, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jTF_ConsumptionMovingUp.setText("1500");
        jTF_ConsumptionMovingUp.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                jTF_ConsumptionMovingUpFocusLost(evt);
            }
        });
        jTF_ConsumptionMovingUp.setBounds(320, 10, 60, 25);
        jLayeredPane1.add(jTF_ConsumptionMovingUp, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel44.setText("WATTS");
        jLabel44.setBounds(400, 10, 60, 25);
        jLayeredPane1.add(jLabel44, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jPanel_Param.add(jLayeredPane1, new org.netbeans.lib.awtextra.AbsoluteConstraints(160, 30, 480, 80));

        jLabel21.setFont(new java.awt.Font("Tahoma", 1, 14));
        jLabel21.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel21.setText("Chargement des paramètres initiaux (statistiques)");
        jPanel_Param.add(jLabel21, new org.netbeans.lib.awtextra.AbsoluteConstraints(150, 150, 510, -1));

        jTable_Stats.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "N° jour", "Heure", "Etage de demande", "Nombre de requêtes"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.Integer.class, java.lang.Integer.class, java.lang.Integer.class, java.lang.Integer.class
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }
        });
        jScrollPane3.setViewportView(jTable_Stats);
        jTable_Stats.getColumnModel().getColumn(3).setResizable(false);

        jPanel_Param.add(jScrollPane3, new org.netbeans.lib.awtextra.AbsoluteConstraints(142, 270, 540, 300));

        jBtn_SaveStats.setText("Sauvegarder");
        jBtn_SaveStats.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBtn_SaveStatsActionPerformed(evt);
            }
        });
        jPanel_Param.add(jBtn_SaveStats, new org.netbeans.lib.awtextra.AbsoluteConstraints(70, 220, 270, -1));

        jBtn_LoadStats.setText("Chargement d'un fichier de statistiques");
        jBtn_LoadStats.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBtn_LoadStatsActionPerformed(evt);
            }
        });
        jPanel_Param.add(jBtn_LoadStats, new org.netbeans.lib.awtextra.AbsoluteConstraints(70, 200, 270, -1));

        jTF_StatsFile.setEnabled(false);
        jPanel_Param.add(jTF_StatsFile, new org.netbeans.lib.awtextra.AbsoluteConstraints(350, 210, 350, -1));

        jBtn_UpdateStats.setText("Charger les paramètres");
        jBtn_UpdateStats.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBtn_UpdateStatsActionPerformed(evt);
            }
        });
        jPanel_Param.add(jBtn_UpdateStats, new org.netbeans.lib.awtextra.AbsoluteConstraints(300, 570, 200, -1));

        jTabbedPane1.addTab("Paramétrage", jPanel_Param);

        jPanel_Controles.setBackground(new java.awt.Color(215, 211, 211));
        jPanel_Controles.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));

        jPanel_Alarm.setBackground(new java.awt.Color(255, 0, 0));
        jPanel_Alarm.setOpaque(false);
        jPanel_Alarm.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jLabel6.setFont(new java.awt.Font("Tahoma", 1, 14));
        jLabel6.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel6.setText("Gestionnaire de simulation");
        jLabel6.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jPanel_Alarm.add(jLabel6, new org.netbeans.lib.awtextra.AbsoluteConstraints(270, 0, -1, -1));

        jPanel_SimulatorControls.setOpaque(false);
        jPanel_SimulatorControls.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jBtn_SimulationStop.setText("Arrêt de la simulation");
        jBtn_SimulationStop.setToolTipText("Mise en arrêt de la simulation");
        jBtn_SimulationStop.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBtn_SimulationStopActionPerformed(evt);
            }
        });
        jPanel_SimulatorControls.add(jBtn_SimulationStop, new org.netbeans.lib.awtextra.AbsoluteConstraints(310, 0, 160, -1));

        jBtn_DivideSpeed.setText("/ 2");
        jBtn_DivideSpeed.setToolTipText("Division de la vitesse par 2");
        jBtn_DivideSpeed.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBtn_DivideSpeedActionPerformed(evt);
            }
        });
        jPanel_SimulatorControls.add(jBtn_DivideSpeed, new org.netbeans.lib.awtextra.AbsoluteConstraints(50, 0, 50, -1));

        jBtn_SimulationStart.setText("Lancer la simulation");
        jBtn_SimulationStart.setToolTipText("Lancement de la simulation");
        jBtn_SimulationStart.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBtn_SimulationStartActionPerformed(evt);
            }
        });
        jPanel_SimulatorControls.add(jBtn_SimulationStart, new org.netbeans.lib.awtextra.AbsoluteConstraints(160, 0, 150, -1));

        jBtn_MultiplySpeed.setText("X2");
        jBtn_MultiplySpeed.setToolTipText("Multiplication de la vitesse par 2");
        jBtn_MultiplySpeed.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBtn_MultiplySpeedActionPerformed(evt);
            }
        });
        jPanel_SimulatorControls.add(jBtn_MultiplySpeed, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, 50, -1));

        jBtn_SimulationAlerte.setText("Alerte !");
        jBtn_SimulationAlerte.setToolTipText("Simulation de l'alarme sur le système");
        jBtn_SimulationAlerte.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBtn_SimulationAlerteActionPerformed(evt);
            }
        });
        jPanel_SimulatorControls.add(jBtn_SimulationAlerte, new org.netbeans.lib.awtextra.AbsoluteConstraints(470, 0, 80, -1));

        jBtn_Reset.setText("Reset");
        jBtn_Reset.setToolTipText("Rechargement du simulateur à l'état initial");
        jBtn_Reset.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBtn_ResetActionPerformed(evt);
            }
        });
        jPanel_SimulatorControls.add(jBtn_Reset, new org.netbeans.lib.awtextra.AbsoluteConstraints(100, 0, -1, -1));

        jPanel_Alarm.add(jPanel_SimulatorControls, new org.netbeans.lib.awtextra.AbsoluteConstraints(80, 30, 550, 30));

        jLabel7.setFont(new java.awt.Font("Tahoma", 1, 12));
        jLabel7.setText("Date :");
        jPanel_Alarm.add(jLabel7, new org.netbeans.lib.awtextra.AbsoluteConstraints(150, 70, -1, -1));

        jLB_SimulationDate.setFont(new java.awt.Font("Tahoma", 0, 12));
        jLB_SimulationDate.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLB_SimulationDate.setText("Samedi 1 janvier 2011 00:00:00");
        jPanel_Alarm.add(jLB_SimulationDate, new org.netbeans.lib.awtextra.AbsoluteConstraints(200, 70, -1, -1));

        jLabel9.setFont(new java.awt.Font("Tahoma", 1, 12));
        jLabel9.setText("Vitesse :");
        jPanel_Alarm.add(jLabel9, new org.netbeans.lib.awtextra.AbsoluteConstraints(460, 70, -1, -1));

        jLB_SimulationSpeed.setFont(new java.awt.Font("Tahoma", 0, 12));
        jLB_SimulationSpeed.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLB_SimulationSpeed.setText("x2");
        jPanel_Alarm.add(jLB_SimulationSpeed, new org.netbeans.lib.awtextra.AbsoluteConstraints(510, 70, 60, -1));

        jBtn_UpdateDate.setText("jButton1");
        jBtn_UpdateDate.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBtn_UpdateDateActionPerformed(evt);
            }
        });
        jPanel_Alarm.add(jBtn_UpdateDate, new org.netbeans.lib.awtextra.AbsoluteConstraints(130, 70, 15, 15));

        jBtn_ChangeLookAndFeel.setText("...");
        jBtn_ChangeLookAndFeel.setToolTipText("Changement du style de la fenêtre");
        jBtn_ChangeLookAndFeel.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBtn_ChangeLookAndFeelActionPerformed(evt);
            }
        });
        jPanel_Alarm.add(jBtn_ChangeLookAndFeel, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, 40, -1));

        jCB_SimulationQuotas.setText("Quotas");
        jCB_SimulationQuotas.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jCB_SimulationQuotasActionPerformed(evt);
            }
        });
        jPanel_Alarm.add(jCB_SimulationQuotas, new org.netbeans.lib.awtextra.AbsoluteConstraints(650, 30, 140, -1));

        jCB_SimulationTests.setText("Jeux d'essais");
        jPanel_Alarm.add(jCB_SimulationTests, new org.netbeans.lib.awtextra.AbsoluteConstraints(650, 10, 140, -1));

        jPanel_Alarm.setBounds(0, 0, 810, 90);
        jLP_Controls.add(jPanel_Alarm, javax.swing.JLayeredPane.DEFAULT_LAYER);

        javax.swing.GroupLayout jPanel_ControlesLayout = new javax.swing.GroupLayout(jPanel_Controles);
        jPanel_Controles.setLayout(jPanel_ControlesLayout);
        jPanel_ControlesLayout.setHorizontalGroup(
            jPanel_ControlesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jLP_Controls, javax.swing.GroupLayout.DEFAULT_SIZE, 811, Short.MAX_VALUE)
        );
        jPanel_ControlesLayout.setVerticalGroup(
            jPanel_ControlesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jLP_Controls, javax.swing.GroupLayout.PREFERRED_SIZE, 93, javax.swing.GroupLayout.PREFERRED_SIZE)
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel_Controles, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 813, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPanel_Controles, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 641, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    /**
     * Evénement levé lors du clic sur le bouton de démarrage de la simulation.
     * @param evt
     */
    private void jBtn_SimulationStartActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtn_SimulationStartActionPerformed

        // Démarrage du simulateur
        simulatorController.start();
}//GEN-LAST:event_jBtn_SimulationStartActionPerformed

    private void jBtn_MultiplySpeedActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtn_MultiplySpeedActionPerformed
        simulatorController.increaseTimeLineSpeed();
}//GEN-LAST:event_jBtn_MultiplySpeedActionPerformed

    private void jBtn_DivideSpeedActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtn_DivideSpeedActionPerformed
        simulatorController.decreaseTimeLineSpeed();
}//GEN-LAST:event_jBtn_DivideSpeedActionPerformed

    /**
     * Evénement levé lors du clic sur le bouton d'arrêt de la simulation.
     * @param evt
     */
    private void jBtn_SimulationStopActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtn_SimulationStopActionPerformed
        // Arrêt du simulateur
        simulatorController.stop();
}//GEN-LAST:event_jBtn_SimulationStopActionPerformed

    private void jTF_TestNameActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTF_TestNameActionPerformed

}//GEN-LAST:event_jTF_TestNameActionPerformed

    private void JBtn_SaveTestFileActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_JBtn_SaveTestFileActionPerformed
        JFileChooser choix = new JFileChooser();
        choix.setFileSelectionMode(JFileChooser.FILES_ONLY);
        if (testFileOpened != null) choix.setSelectedFile(testFileOpened);
        int retour = choix.showSaveDialog(this);

        // Si un fichier est sélectionné.
        if (retour == JFileChooser.APPROVE_OPTION) {

            // Sauvegarde du fichier
            testFileOpened = choix.getSelectedFile();
            if (SaveTestFile(choix.getSelectedFile())) {

                // Mise à jour du nom dans le champs.
                jTF_TestName.setText(testFileOpened.getAbsolutePath());

                MessageManager.ShowInformationMessage(this, "Sauvegarde du jeu d'essai réussi.");
            }
            else {
                MessageManager.ShowInformationMessage(this, "Echec de la sauvegarde du jeu d'essai.");
            }
        }
    }//GEN-LAST:event_JBtn_SaveTestFileActionPerformed

    
    /**
     * Evénement appelé lors de la sauvegarde des quotas.
     * @param evt
     */
    private void JBtn_SaveStatsFileActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_JBtn_SaveStatsFileActionPerformed
        JFileChooser choix = new JFileChooser();
        choix.setFileSelectionMode(JFileChooser.FILES_ONLY);

        if (quotaFileOpened != null)
            choix.setSelectedFile(quotaFileOpened);

        int retour = choix.showSaveDialog(this);

        // Si un fichier est sélectionné.
        if (retour == JFileChooser.APPROVE_OPTION) {
            if (SaveQuotaFile(choix.getSelectedFile())) {
                MessageManager.ShowInformationMessage(this, "Sauvegarde des quotas réussi.");
            } else {
                MessageManager.ShowInformationMessage(this, "Echec de la sauvegarde des quotas.");
            }
        }
    }//GEN-LAST:event_JBtn_SaveStatsFileActionPerformed

    /**
     * Evénement levé lors du clic sur le bouton de chargement des quotas.
     * @param evt
     */
    private void JBtn_LoadStatsFileActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_JBtn_LoadStatsFileActionPerformed

        JFileChooser choix = new JFileChooser();
        choix.setFileSelectionMode(JFileChooser.FILES_ONLY);

        if (quotaFileOpened != null)
            choix.setSelectedFile(quotaFileOpened);

        int retour = choix.showOpenDialog(this);

        // Si un fichier est sélectionné.
        if (retour == JFileChooser.APPROVE_OPTION) {
            // Sauvegarde du fichier
            quotaFileOpened = choix.getSelectedFile();

            // Chargement du fichier
            if (LoadQuotaFile()) {
                jTextField_QuotaName.setText(quotaFileOpened.getName());

                MessageManager.ShowInformationMessage(this, "Chargement des quotas réussi.");
            } else
                MessageManager.ShowInformationMessage(this, "Echec du chargement des quotas.");
        }
    }//GEN-LAST:event_JBtn_LoadStatsFileActionPerformed

    /**
     * Evénement appelé lors d'un clic sur le bouton de chargement d'un fichier
     * de jeux d'essai.
     * @param evt
     */
    private void JBtn_LoadTestFileActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_JBtn_LoadTestFileActionPerformed

        JFileChooser choix = new JFileChooser();
        choix.setFileSelectionMode(JFileChooser.FILES_ONLY);

        if (testFileOpened != null)
            choix.setSelectedFile(testFileOpened);

        // Ouverture de la fenêtre de choix.
        int retour = choix.showOpenDialog(this);

        // Si un fichier est sélectionné.
        if (retour == JFileChooser.APPROVE_OPTION) {

            // Sauvegarde du fichier
            testFileOpened = choix.getSelectedFile();

            // Chargement du fichier
            if (LoadTestFile()) {

                // Mise à jour du nom dans le champs.
                jTF_TestName.setText(testFileOpened.getAbsolutePath());

                MessageManager.ShowInformationMessage(this, "Chargement du jeu d'essai réussi.");
            } else
                MessageManager.ShowInformationMessage(this, "Echec du chargement du jeu d'essai.");
        }
    }//GEN-LAST:event_JBtn_LoadTestFileActionPerformed

    /**
     * Evénement levé lors du clic sur le bouton d'ajout directe d'une requete.
     * @param evt
     */
    private void jBtn_AddDirectRequestActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtn_AddDirectRequestActionPerformed
        dialogTest.showPopup(MODE.DIRECT);
}//GEN-LAST:event_jBtn_AddDirectRequestActionPerformed

    private void jButton_DeleteRequestActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_DeleteRequestActionPerformed
        DefaultTableModel model = (DefaultTableModel)jTable_Tests.getModel();
        if(model.getRowCount() != 0)
        {
            int [] selectedRows = jTable_Tests.getSelectedRows();
            for(int i=0 ; i<selectedRows.length ; i++)
                model.removeRow(i);
        }
        else
            MessageManager.ShowInformationMessage(this, "Vous devez sélectionner une requête du jeu d'essai à supprimer.");
}//GEN-LAST:event_jButton_DeleteRequestActionPerformed

    private void jBtn_AddRequestActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtn_AddRequestActionPerformed
        dialogTest.showPopup(MODE.NORMAL);
}//GEN-LAST:event_jBtn_AddRequestActionPerformed

    /**
     * Evénement levé lors du clic sur le bouton de suppression de tous les jeux d'essais.
     * @param evt
     */
    private void jButton_ClearAllRequestActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_ClearAllRequestActionPerformed
        DefaultTableModel model = (DefaultTableModel) jTable_Tests.getModel();

        // On vide les lignes courantes.
        while (model.getRowCount() != 0) {
            model.removeRow(0);
        }
    }//GEN-LAST:event_jButton_ClearAllRequestActionPerformed

    /**
     * Méthode de redémarrage du simulateur.
     * @param evt
     */
    private void jBtn_ResetActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtn_ResetActionPerformed

        // Réinitialisation de la date du simulateur.
        simulatorController.reset();

        // Réinitialisation des labels
        jLB_ConsoEcospeed.setText("0");
        jLB_ConsoStandard.setText("0");
        jLB_ProcessedRequestsEcospeed.setText("0");
        jLB_ProcessedRequestsStandard.setText("0");
        jLB_WaitingTimeEcospeed.setText("0");
        jLB_WaitingTimeStandard.setText("0");

        // Si la checkbox des jeux d'essais est cochée
        // on génère les requêtes sur le simulateur.
        if(jCB_SimulationTests.isSelected())
        {
            // Ajout des requêtes dans le jTableTests au simulateur.
            GenerateRequestsFromTable();
        }

        // Si la checkBox des quotas est cochée
        // on sauvegarde les quotas dans le simulateur.
        if(jCB_SimulationQuotas.isSelected())
        {
            SaveQuotaToSimulator();
        }

        // Affichage du message
        MessageManager.ShowInformationMessage(this, "Réinitialisation du Simulateur réussi.");
    }//GEN-LAST:event_jBtn_ResetActionPerformed

    private void jBtn_SimulationAlerteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtn_SimulationAlerteActionPerformed
        simulatorController.switchAlarm();
    }//GEN-LAST:event_jBtn_SimulationAlerteActionPerformed

    private void jBtn_ClearAllQuotasActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtn_ClearAllQuotasActionPerformed
        DefaultTableModel model = (DefaultTableModel) jTable_Quotas.getModel();

        // On vide les lignes courantes.
        while (model.getRowCount() != 0) {
            model.removeRow(0);
        }
}//GEN-LAST:event_jBtn_ClearAllQuotasActionPerformed

    private void jBtn_DeleteQuotaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtn_DeleteQuotaActionPerformed
        DefaultTableModel model = (DefaultTableModel)jTable_Quotas.getModel();
        if(model.getRowCount() != 0)
        {
            int [] selectedRows = jTable_Quotas.getSelectedRows();
            for(int i=0 ; i<selectedRows.length ; i++)
                model.removeRow(i);
        }
        else
            MessageManager.ShowInformationMessage(this, "Vous devez sélectionner une quota à supprimer.");
    }//GEN-LAST:event_jBtn_DeleteQuotaActionPerformed

    private void jCB_SimulationQuotasActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCB_SimulationQuotasActionPerformed
        simulatorController.setActivQuota(jCB_SimulationQuotas.isSelected());
    }//GEN-LAST:event_jCB_SimulationQuotasActionPerformed

    private void jBtn_AddQuotaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtn_AddQuotaActionPerformed
        dialogQuota.showPopup();
}//GEN-LAST:event_jBtn_AddQuotaActionPerformed

    private void jBtn_ChangeLookAndFeelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtn_ChangeLookAndFeelActionPerformed
        if (currentLookAndFeel == lookAndFeelInfos.length -1) {
            currentLookAndFeel = 0;
        } else {
            currentLookAndFeel++;
        }

        updateLookAndFeel(lookAndFeelInfos[currentLookAndFeel].getClassName());
    }//GEN-LAST:event_jBtn_ChangeLookAndFeelActionPerformed

    private void jBtn_UpdateDateActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtn_UpdateDateActionPerformed
        dialogDate.showPopup();
    }//GEN-LAST:event_jBtn_UpdateDateActionPerformed

    private void jTF_ConsumptionMovingUpFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTF_ConsumptionMovingUpFocusLost
        try {
            int i = Integer.parseInt(jTF_ConsumptionMovingUp.getText());
            if(i<0) throw new Exception();
        }
        catch (Exception ex) {
            MessageManager.ShowInformationMessage(this, "La consommation de montée doit être un entier positif");
            jTF_ConsumptionMovingUp.setText("1500");
        }
    }//GEN-LAST:event_jTF_ConsumptionMovingUpFocusLost

    private void jTF_ConsumptionMovingDownFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTF_ConsumptionMovingDownFocusLost
         try {
            int i = Integer.parseInt(jTF_ConsumptionMovingDown.getText());
            if(i<0) throw new Exception();
        }
        catch (Exception ex) {
            MessageManager.ShowInformationMessage(this, "La consommation de descente doit être un entier positif");
            jTF_ConsumptionMovingDown.setText("750");
        }
    }//GEN-LAST:event_jTF_ConsumptionMovingDownFocusLost

    private void jBtn_LoadStatsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtn_LoadStatsActionPerformed
        JFileChooser choix = new JFileChooser();
        choix.setFileSelectionMode(JFileChooser.FILES_ONLY);

        if (statsFileOpened != null)
            choix.setSelectedFile(statsFileOpened);

        // Ouverture de la fenêtre de choix.
        int retour = choix.showOpenDialog(this);

        // Si un fichier est sélectionné.
        if (retour == JFileChooser.APPROVE_OPTION) {

            // Sauvegarde du fichier
            statsFileOpened = choix.getSelectedFile();

            // Chargement du fichier
            if (LoadStatsFile()) {

                // Mise à jour du nom dans le champs.
                jTF_StatsFile.setText(statsFileOpened.getAbsolutePath());

                MessageManager.ShowInformationMessage(this, "Chargement des statistiques réussi.");
            } else
                MessageManager.ShowInformationMessage(this, "Erreur du chargement des statistiques.");
        }

    }//GEN-LAST:event_jBtn_LoadStatsActionPerformed

    private void jBtn_SaveStatsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtn_SaveStatsActionPerformed
        JFileChooser choix = new JFileChooser();
        choix.setFileSelectionMode(JFileChooser.FILES_ONLY);

        if (statsFileOpened != null)
            choix.setSelectedFile(statsFileOpened);

        int retour = choix.showSaveDialog(this);

        // Si un fichier est sélectionné.
        if (retour == JFileChooser.APPROVE_OPTION) {
            if (SaveStatsFile(choix.getSelectedFile())) {
                MessageManager.ShowInformationMessage(this, "Sauvegarde des statistiques réussi.");
            } else {
                MessageManager.ShowInformationMessage(this, "Echec de la sauvegarde des statistiques.");
            }
        }
    }//GEN-LAST:event_jBtn_SaveStatsActionPerformed

    private void jBtn_UpdateStatsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtn_UpdateStatsActionPerformed
        UpdateSimulatorStats();
    }//GEN-LAST:event_jBtn_UpdateStatsActionPerformed

    /**
     * Evénement levé lors du clic sur le bouton de sauvegarde de la simulation.
     * @param evt
     */
    private void jBtn_SaveSimulationActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtn_SaveSimulationActionPerformed
        JFileChooser choix = new JFileChooser();
        choix.setFileSelectionMode(JFileChooser.FILES_ONLY);

        if (testFileOpened != null)
            choix.setSelectedFile(testFileOpened);

        int retour = choix.showSaveDialog(this);

        // Si un fichier est sélectionné.
        if (retour == JFileChooser.APPROVE_OPTION) {
            try {
                // Récupération de toutes les requetes
                Vector<Request> requestsList = simulatorController.getFinishRequestsStandardList();
                FileWriter fw = new FileWriter(choix.getSelectedFile());
                BufferedWriter out = new BufferedWriter(fw);
                out.write("");

                Iterator it = requestsList.iterator();
                while (it.hasNext()) {
                    
                    Request r = (Request) it.next();
                    
                    // Ecriture de ces informations dans le fichier.
                    out.write(new SimpleDateFormat("MM-dd-yyyy HH:mm:ss").format(r.getLaunchDate()) + "  ");
                    out.write(r.getStartFloor() + "  ");
                    out.write(r.getEndFloor() + "  ");
                    out.write(r.getWeight() + "  ");
                    out.write(r.getUrgent() ? "1" : "0" + "\n");
                }
                out.close();
            }
            catch (IOException ex) {
                MessageManager.ShowErrorMessage(this, MessageManager.errorInWritingFileFormat, ex);
            }
        }

    }//GEN-LAST:event_jBtn_SaveSimulationActionPerformed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton JBtn_LoadStatsFile;
    private javax.swing.JButton JBtn_LoadTestFile;
    private javax.swing.JButton JBtn_SaveStatsFile;
    private javax.swing.JButton JBtn_SaveTestFile;
    private javax.swing.JPanel Panel_Ecospeed;
    private javax.swing.JPanel Panel_Informations;
    private javax.swing.JPanel Panel_Standard;
    private javax.swing.JSlider ascenseurEco_1;
    private javax.swing.JSlider ascenseurEco_2;
    private javax.swing.JSlider ascenseurEco_3;
    private javax.swing.JSlider ascenseurEco_4;
    private javax.swing.JSlider ascenseurEco_5;
    private javax.swing.JSlider ascenseurEco_6;
    private javax.swing.JSlider ascenseurStd_1;
    private javax.swing.JSlider ascenseurStd_2;
    private javax.swing.JSlider ascenseurStd_3;
    private javax.swing.JSlider ascenseurStd_4;
    private javax.swing.JSlider ascenseurStd_5;
    private javax.swing.JSlider ascenseurStd_6;
    private javax.swing.JButton jBtn_AddDirectRequest;
    private javax.swing.JButton jBtn_AddQuota;
    private javax.swing.JButton jBtn_AddRequest;
    private javax.swing.JButton jBtn_ChangeLookAndFeel;
    private javax.swing.JButton jBtn_ClearAllQuotas;
    private javax.swing.JButton jBtn_DeleteQuota;
    private javax.swing.JButton jBtn_DivideSpeed;
    private javax.swing.JButton jBtn_LoadStats;
    private javax.swing.JButton jBtn_MultiplySpeed;
    private javax.swing.JButton jBtn_Reset;
    private javax.swing.JButton jBtn_SaveSimulation;
    private javax.swing.JButton jBtn_SaveStats;
    private javax.swing.JButton jBtn_SimulationAlerte;
    private javax.swing.JButton jBtn_SimulationStart;
    private javax.swing.JButton jBtn_SimulationStop;
    private javax.swing.JButton jBtn_UpdateDate;
    private javax.swing.JButton jBtn_UpdateStats;
    private javax.swing.JButton jButton_ClearAllRequest;
    private javax.swing.JButton jButton_DeleteRequest;
    private javax.swing.JCheckBox jCB_SimulationQuotas;
    private javax.swing.JCheckBox jCB_SimulationTests;
    private javax.swing.JLabel jLB_ConsoEcospeed;
    private javax.swing.JLabel jLB_ConsoStandard;
    private javax.swing.JLabel jLB_ProcessedRequestsEcospeed;
    private javax.swing.JLabel jLB_ProcessedRequestsStandard;
    private javax.swing.JLabel jLB_SimulationDate;
    private javax.swing.JLabel jLB_SimulationSpeed;
    private javax.swing.JLabel jLB_WaitingTimeEcospeed;
    private javax.swing.JLabel jLB_WaitingTimeStandard;
    private javax.swing.JLayeredPane jLP_Controls;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel21;
    private javax.swing.JLabel jLabel25;
    private javax.swing.JLabel jLabel26;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel33;
    private javax.swing.JLabel jLabel34;
    private javax.swing.JLabel jLabel35;
    private javax.swing.JLabel jLabel36;
    private javax.swing.JLabel jLabel37;
    private javax.swing.JLabel jLabel38;
    private javax.swing.JLabel jLabel39;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel40;
    private javax.swing.JLabel jLabel41;
    private javax.swing.JLabel jLabel42;
    private javax.swing.JLabel jLabel43;
    private javax.swing.JLabel jLabel44;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JLayeredPane jLayeredPane1;
    private javax.swing.JLayeredPane jLayeredPane_simulation;
    private javax.swing.JPanel jPanel10;
    private javax.swing.JPanel jPanel11;
    private javax.swing.JPanel jPanel12;
    private javax.swing.JPanel jPanel13;
    private javax.swing.JPanel jPanel14;
    private javax.swing.JPanel jPanel15;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JPanel jPanel7;
    private javax.swing.JPanel jPanel8;
    private javax.swing.JPanel jPanel9;
    private javax.swing.JPanel jPanel_Alarm;
    private javax.swing.JPanel jPanel_Controles;
    private javax.swing.JPanel jPanel_Param;
    private javax.swing.JPanel jPanel_SimulatorControls;
    private javax.swing.JPanel jPanel_jeuxEssais;
    private javax.swing.JPanel jPanel_statistiques;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JTextField jTF_ConsumptionMovingDown;
    private javax.swing.JTextField jTF_ConsumptionMovingUp;
    private javax.swing.JTextField jTF_StatsFile;
    private javax.swing.JTextField jTF_TestName;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JTable jTable_Quotas;
    private javax.swing.JTable jTable_Stats;
    private javax.swing.JTable jTable_Tests;
    private javax.swing.JTextField jTextField_QuotaName;
    // End of variables declaration//GEN-END:variables
    private class MySlider extends javax.swing.JSlider implements Observer {
        public void update(Observable o, Object arg) {
            if (o instanceof DriverLift) {
                DriverLift d = (DriverLift)o;
                this.setValue(d.getFloor()-(EcoSpeed.Utils.NB_UNDERGROUND));
            }
            else if(o instanceof StandardDriverLift){
                StandardDriverLift d = (StandardDriverLift) o;
                this.setValue(d.getFloor()-(EcoSpeed.Utils.NB_UNDERGROUND));
            }
        }
    }

    private class MyLabel extends javax.swing.JLabel implements Observer {
        public void update(Observable o, Object arg) {
            if (o instanceof Simulator) {
                // Récupération du simulateur.
                Simulator sim = (Simulator) o;

                // Récupération de la date
                Date date = sim.getDate();
                
                // Mise à jour du label
                jLB_SimulationDate.setText(new SimpleDateFormat("EEEE d MMMM yyyy  HH:mm:ss").format(date));
            }
        }
    }

    private class SpeedLabel extends javax.swing.JLabel implements Observer {
        public void update(Observable o, Object arg) {
            if (o instanceof Simulator) {

                // Récupération du simulateur.
                Simulator sim = (Simulator) o;

                // Récupération de la vitesse.
                int speed = sim.getSpeed();

                // Mise à jour de la vitesse.
                jLB_SimulationSpeed.setText("x" + speed);

            }
        }
    }

    private class AlarmPanel extends javax.swing.JPanel implements Observer {
        public void update(Observable o, Object arg) {
            if (o instanceof Alarme) {
                // Récupération de l'alarme
                Alarme alarm = (Alarme) o;
                this.setOpaque(alarm.getStatut());
                this.updateUI();
                instance.repaint();
            }
        }
    }

    private class NbDemandeLabel extends javax.swing.JLabel implements Observer {
	    private boolean EcoSpeed;
	    public NbDemandeLabel(boolean val){
		    this.EcoSpeed = val;
	    }
		public void update(Observable o, Object o1) {
			if(o instanceof Simulator){
				Simulator s = (Simulator)o;
				if(this.EcoSpeed){
					this.setText(Integer.toString(s.getFinishRequestsEcoSpeedList().size()));
				}
				else{
					this.setText(Integer.toString(s.getFinishRequestsStandardList().size()));
				}
			}
		}

    }

    private class DelayLabel extends javax.swing.JLabel implements Observer {
	    private boolean EcoSpeed;
	    public DelayLabel(boolean val){
		    this.EcoSpeed = val;
	    }
	    public int avg(Vector<Request> list) {
		    int n = list.size();
		    int avg = 0;
		    if(n > 0){
			    int sum = 0;
			    Iterator it = list.iterator();
			    Request r;
			    while(it.hasNext()){
				    r = (Request)it.next();
				    sum += ((r.getEndDate().getTime() - r.getLaunchDate().getTime()) / 1000);
			    }
			    avg = sum/n;
		    }
		    return avg;
	    }

		public void update(Observable o, Object o1) {
			if(o instanceof Simulator){
				Simulator s = (Simulator)o;
				if(this.EcoSpeed){
					this.setText(Integer.toString(this.avg(s.getFinishRequestsEcoSpeedList())));
				}
				else{
					this.setText(Integer.toString(this.avg(s.getFinishRequestsStandardList())));

				}
			}
		}
    }


    private class ConsoLabel extends javax.swing.JLabel implements Observer {
        public void update(Observable o, Object arg) {
            if (o instanceof DriverLift || o instanceof StandardDriverLift) {
                    int move = (Integer) arg;
                    double conso = Double.parseDouble(this.getText());
                    double descConso = (Double.parseDouble(jTF_ConsumptionMovingDown.getText()) / 1000);
                    double ascConso = (Double.parseDouble(jTF_ConsumptionMovingUp.getText()) / 1000);

                    // L'ascenseur descend
                    if (move == -1) {
                        conso += descConso;
                    } // S'il monte
                    else if (move == 1) {
                        conso += ascConso;
                    }
                    

		    this.setText(Double.toString(conso));
            }
        }
    }



    private static class MessageManager
    {
        public static String errorInLoadingLookAndFeel = "Une erreur est survenue lors du chargement du style de la fenêtre.";
        public static String errorInReadingFileFormat = "Le fichier à lire n'est pas dans un format correct. Impossible de charger les informations.";
        public static String errorInWritingFileFormat = "Une erreur est survenue lors de l'ouverture du fichier de sauvegarde des données.";
        public static String errorInOpeningFile = "Impossible de lire le fichier sélectionné.";
        public static String unvalidTestTableInformation = "Une erreur est survenue lors de la lecture du jeu d'essai courant. Format incorrect.";
        public static String errorInAddDirectRequest = "Une erreur est survenue lors de l'ajout directe d'une requête. Format incorrect.";
        public static String errorInLoadingStats = "Une erreur est survenue lors du chargement des statistiques dans le simulateur.";

        public static String errorInUpdatingConso = "Une erreur est survenue lors de la modification d'une consommation.";

        public static void ShowErrorMessage(JFrame f, String UserMessage, Exception ex)
        {
            JOptionPane.showMessageDialog(f, UserMessage + "\n" + ex.getClass().getName() + ": " + ex.getMessage(), "Erreur", JOptionPane.ERROR_MESSAGE);
        }
        public static void ShowInformationMessage(JFrame f, String information)
        {
            JOptionPane.showMessageDialog(f, information, "Erreur", JOptionPane.INFORMATION_MESSAGE);
        }
    }
}
